package com.mytest.example.gobrs.task.chain4;

import com.gobrs.async.TaskSupport;
import com.gobrs.async.anno.Task;
import com.gobrs.async.task.AsyncTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;


@Slf4j
@Task(retryCount = 3)
@Component
public class Chain4TaskC extends AsyncTask<Chain4Param1, String> {
    @Override
    public void prepare(Chain4Param1 o) {

    }

    @Override
    public String task(Chain4Param1 o, TaskSupport taskSupport) {
        log.info("Chain4TaskC cancel={},shouldThrow={}", o.getCancel(), o.getShouldThrow());
        return "Chain4TaskC";
    }

    @Override
    public boolean nessary(Chain4Param1 o, TaskSupport taskSupport) {
        return true;
    }

    @Override
    public void onSuccess(TaskSupport taskSupport) {
        log.info("Chain4TaskC 执行完成");

    }

    @Override
    public void onFail(TaskSupport taskSupport) {
        //在任务异常时发送告警信息
        log.error("Chain4TaskC 执行失败,ex={}", taskSupport.getResultMap().get(this.getClass()).getEx().getMessage());

    }
}
